package com.iknow.xmpp.extention;

import com.iknow.xmpp.service.Friend;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.jivesoftware.smack.packet.IQ;

public class UserInfomationIQ extends IQ
{
  private Map<String, String> childList = new HashMap();
  private Map<String, Map<String, String>> chileAttributes = new HashMap();
  private List<Friend> mFriendList = new ArrayList();

  public void addAttributes(String paramString1, String paramString2, String paramString3)
  {
    if (this.chileAttributes.containsKey(paramString1))
      ((Map)this.chileAttributes.get(paramString1)).put(paramString2, paramString3);
    while (true)
    {
      return;
      HashMap localHashMap = new HashMap();
      localHashMap.put(paramString2, paramString3);
      this.chileAttributes.put(paramString1, localHashMap);
    }
  }

  public void addFriend(Friend paramFriend)
  {
    this.mFriendList.add(paramFriend);
  }

  public void clearAttributes()
  {
    this.childList.clear();
  }

  public void clearFriendList()
  {
    this.mFriendList.clear();
  }

  public Map<String, String> getAttributes()
  {
    return this.childList;
  }

  public String getChildElementXML()
  {
    Iterator localIterator1;
    Iterator localIterator2;
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<user xmlns=\"http://www.imiknow.com/iks/xmpp/iq/user\">");
    if (this.chileAttributes.size() > 0)
    {
      localIterator2 = this.chileAttributes.entrySet().iterator();
      if (localIterator2.hasNext())
        break label110;
    }
    if ((this.childList != null) && (this.childList.size() > 0))
      localIterator1 = this.childList.keySet().iterator();
    while (true)
    {
      if (!(localIterator1.hasNext()))
      {
        localStringBuilder.append("</user>");
        return localStringBuilder.toString();
        label110: Map.Entry localEntry1 = (Map.Entry)localIterator2.next();
        String str3 = (String)localEntry1.getKey();
        Map localMap = (Map)localEntry1.getValue();
        localStringBuilder.append("<" + str3 + " ");
        Iterator localIterator3 = localMap.entrySet().iterator();
        while (true)
        {
          while (!(localIterator3.hasNext()))
            localStringBuilder.append("/>");
          Map.Entry localEntry2 = (Map.Entry)localIterator3.next();
          localStringBuilder.append(localEntry2.getKey() + "=");
          localStringBuilder.append("\"" + localEntry2.getValue() + "\"");
          localStringBuilder.append(" ");
        }
      }
      String str1 = (String)localIterator1.next();
      String str2 = (String)this.childList.get(str1);
      localStringBuilder.append("<").append(str1).append(">");
      localStringBuilder.append(str2);
      localStringBuilder.append("</").append(str1).append(">");
    }
  }

  public String getFieldValue(String paramString)
  {
    return ((String)this.childList.get(paramString));
  }

  public Friend getFriendByIndex(int paramInt)
  {
    Friend localFriend;
    if ((paramInt < 0) || (paramInt > this.mFriendList.size()))
      localFriend = null;
    while (true)
    {
      return localFriend;
      localFriend = (Friend)this.mFriendList.get(paramInt);
    }
  }

  public int getFriendListCount()
  {
    return this.mFriendList.size();
  }

  public void put(String paramString1, String paramString2)
  {
    this.childList.put(paramString1, paramString2);
  }
}